/*
 * @Author: 肖芬芳 1911683843@qq.com
 * @Date: 2022-11-17 16:46:20
 * @LastEditors: 肖芬芳 1911683843@qq.com
 * @LastEditTime: 2022-11-18 16:24:47
 * @FilePath: \blog\routes\admin\system\user\changeStatus.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const { ObjectId } = require('mongodb');
const { User } = require('../../../../model/user.js');
module.exports = async(req, res) => {
    if(req.fields.id!=null){
        // console.log(req.fields.id)
        let data=await User.findOne({_id:ObjectId(req.fields.id)})
        let origianlStatus=data.status
        await User.find({_id:ObjectId(req.fields.id)}).updateOne({status:origianlStatus==0?1:0})
        res.send({ 'code': 0});
    }else{
        res.send({ 'code': 0,'msg':"id不能为空"});
    }
    
}